package edu.sctu.practice.class02.lvchang.test12;

/**
 * Created by Administrator on 2015/10/16.
 */
public class TestCar {

    public int numOfTires;//轮胎数量
    public String colorOfCar;//汽车颜色
    public float weightOfCar;//车重  单位：顿

    /*
    * 无参构造方法
    */
    public TestCar() {
        this.numOfTires = 4;
        this.colorOfCar = "red";
        this.weightOfCar = 1.5f;
    }

    /*
    *有参构造方法
     */
    public TestCar(int numOfTires, String colorOfCar, float weightOfCar) {
        this.numOfTires = numOfTires;
        this.colorOfCar = colorOfCar;
        this.weightOfCar = weightOfCar;
    }


    public void stop() {
        System.out.println("汽车可以停下来！");
    }


    public void accelerate() {
        System.out.println("汽车可以加速！");
    }

    public void decelerate() {

        System.out.println("汽车可以减速！");
    }

    public static void main(String[] args) {
        TestCar testCar = new TestCar();
        System.out.println("第一辆：");
        System.out.println("轮胎数：" + testCar.numOfTires + " 颜色：" + testCar.colorOfCar + " 车重：" + testCar.weightOfCar);

        TestCar testCar1 = new TestCar(5, "black", 1.6f);
        System.out.println("************************");
        System.out.println("第二辆：");
        System.out.println("轮胎数：" + testCar1.numOfTires + " 颜色：" + testCar1.colorOfCar + " 车重：" + testCar1.weightOfCar);
        testCar1.accelerate();
        testCar1.decelerate();
        testCar1.stop();
    }
}
